<?php
/* -------------------------------------------------------------------------------------
* 	ID:						$Id: bestseller.php 11 2013-09-21 11:43:11Z phone.mueller@googlemail.com $
* 	Letzter Stand:			$Revision: 11 $
* 	zuletzt geaendert von:	$Author: siekiera $
* 	Datum:					$Date: 2013-09-21 11:43:11 +0000 (Sat, 21 Sep 2013) $
*
* 	SEO:mercari by Siekiera Media
* 	http://www.seo-mercari.de
*
* 	Copyright (c) since 2011 SEO:mercari
* --------------------------------------------------------------------------------------
* 	based on:
* 	(c) 2000-2001 The Exchange Project  (earlier name of osCommerce)
* 	(c) 2002-2003 osCommerce - www.oscommerce.com
* 	(c) 2003     nextcommerce - www.nextcommerce.org
* 	(c) 2005     xt:Commerce - www.xt-commerce.com
*
* 	Released under the GNU General Public License
* ----------------------------------------------------------------------------------- */

$products = $db->db_query_limit("SELECT
									p.products_id,
									p.products_ordered,
									pd.products_name
								FROM
									" . TABLE_PRODUCTS . " p,
									" . TABLE_PRODUCTS_DESCRIPTION . " pd
								WHERE
									pd.products_id = p.products_id
								AND
									pd.language_id = '" . $_SESSION['languages_id'] . "'
								AND
									p.products_ordered > 0
								GROUP BY
									pd.products_id
								ORDER BY
									p.products_ordered DESC, pd.products_name", 20, true);
?>
<table width="100%" class="dataTable">
	<?php
	if($products->_numOfRows > 0) {
		echo '<tr><td>'.TEXT_WIDGET_BESTSELLERS_NAME.'</td><td width="1">'.TEXT_WIDGET_BESTSELLERS_AMOUNT.'</td></tr>';
		while(!$products->EOF) {
			echo '<tr>';
			echo '	<td>'.$products->fields['products_name'].'</td>';
			echo '	<td align="center">'.$products->fields['products_ordered'].'</td>';
			echo '</tr>';
			$products->MoveNext();
		}
	} else
		echo '<tr><td align="center">'.TEXT_WIDGET_BESTSELLERS_UNSOLD.'</td></tr>';
	?>
</table>